class EventStore<T> {
  constructor(
    public eventName: string, //事件名称
    public eventParam?: T //事件参数
  ) {}

  emit = (eventParam?: T) => {
    uni.$emit(this.eventName, eventParam)
  }

  on = (fn: (param: T) => any) => {
    uni.$on(this.eventName, fn)
  }

  once = (fn: (param: T) => any) => {
    uni.$once(this.eventName, fn)
  }

  off = (callback?) => {
    uni.$off(this.eventName, callback)
  }
}

export default EventStore
